//---------------------------------------------------------------------------

#include "vcl_stl.h"
#pragma hdrstop

#include "h_base.h"
#include "h_xml.h"
#include "h_global.h"
using namespace h_base;
using namespace h_xml;

#include "h_g.h"
#include "h_i18n.h"

#include "t_downloadform.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TDownloadForm *DownloadForm;
//---------------------------------------------------------------------------
__fastcall TDownloadForm::TDownloadForm(TComponent* Owner)
   : TForm(Owner)
{
}
//---------------------------------------------------------------------------
bool __fastcall TDownloadForm::GetFileName(UTF8String &SrcFileName, UTF8String &DesFileName)
{
   if ( ComboBoxFileName->Text == "" )
   {
      ComboBoxFileName->Text = "current.sbt";
   }

   OkFlag = false;
   ShowModal();

   if ( !OkFlag )
   {
      return false;
   }

   UTF8String Str = ComboBoxFileName->Text;
   const char *s = Str.c_str();
   const char *FileName = s;

   for ( ; *s != '\0'; s++ )
   {
      if ( *s == '/' )
      {
         FileName = s + 1;
      }
   }

   SaveDialog1->DefaultExt = "";
   SaveDialog1->FileName = UTF8String(FileName);
   SaveDialog1->Filter =
      "Sim bat files (*.sbt)|*.sbt|Comma-Separated Values (*.csv)|*.csv|All files (*.*)|*.*";
   SaveDialog1->FilterIndex = 3;

   if ( SaveDialog1->InitialDir == "" )
   {
      SaveDialog1->InitialDir = h_g::BaseDir + "bats";
   }

   SaveDialog1->Options = TOpenOptions() << ofOverwritePrompt
      << ofEnableSizing;
   SaveDialog1->Title = UTF8String(h_g::I18nString("t_downloadform:SAVE_FILE_AS"));

   if( !SaveDialog1->Execute() )
   {
      return false;
   }

   SrcFileName = ComboBoxFileName->Text;
   DesFileName = SaveDialog1->FileName;
   return true;
}
void __fastcall TDownloadForm::ButtonOkClick(TObject *Sender)
{
   Close();
   OkFlag = true;
}
//---------------------------------------------------------------------------
void __fastcall TDownloadForm::ButtonCancelClick(TObject *Sender)
{
   Close();
}
//---------------------------------------------------------------------------
